package TestLocalInner;

/**
 * 局部内部类限制类的使用
 */
public class TestLocal {
    public static void main(String[] args) {
//学校开设新班
        //需要高级的老师
//        Teacher teacher =new TallTeacher();
//        teacher.teach();
        //校方没有这么多的高级老师,校方出台了一个规则
        //按照奇数偶数的来分,奇数为初级,偶数为高级
     Teacher  t=  School.getTeacher(1);
     t.teach();
    }
}
class School{
    public  static Teacher getTeacher(int classNo){
        //初级老师
        class DiTeacher extends  Teacher{
            public void teach(){
                System.out.println("老师在上课");
            }
        }
        //高级老师
        class TallTeacher extends  Teacher{
            public void teach(){
                System.out.println("高级老师在上课");
            }
        }
        Teacher currentTeacher =null;//返回值
        if(classNo%2!=0){
     currentTeacher=       new DiTeacher();
        }else{
     currentTeacher=       new TallTeacher();
        }
        return currentTeacher;
    }
}
abstract class Teacher{
    public abstract void teach();


}
